
version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
		cd "${outdir}"
		

	    log using cow_prep, replace t
* ------------------------------------------------------------------------------
* Date : July 2017 [chkd oct 2021]


* Project : Mena Economic Monitor, Fall 2016 edition (MNACE, The World Bank)


* This do file prepares the COW database for merge

* Database used : WRP_national2.csv


* Output : cow.dta

* ------------------------------------------------------------------------------


*                      ---------------------------
*                      ----------COW Data---------
*                      ---------------------------


insheet using "${datadir}/WRP_national2.csv", clear

*Labeling variable

label variable year "Year"
label variable state "COW state number"
label variable name "CWO state abbreviation"
label variable chrstprot "Christianity—Protestants—No. of Adherents"
label variable chrstcat "Christianity—Roman Catholics—No. of Adherents"
label variable chrstorth "Christianity—Eastern Orthodox—No. of Adherents"
label variable chrstang "Christianity—Anglican—No. of Adherents"
label variable chrstothr "Christianity—Others—No. of Adherents"
label variable chrstgen "Christianity—Total No. of Adherents"
label variable judorth "Judaism—Orthodox—No. of Adherents"
label variable jdcons "Judaism—Conservatives—No. of Adherents"
label variable judref "Judaism—Reform—No. of Adherents"
label variable judothr "Judaism--Others—No. of Adherents"
label variable judgen "Judaism—Total No. of Adherents"
label variable islmsun "Islam—Sunni—No. of Adherents"
label variable islmshi "Islam—Shi’a—No. of Adherents"
label variable islmibd "Islam--Ibadhi—No. of Adherents"
label variable islmnat "Islam—Nation of Islam—No. of Adherents"
label variable islmalw "Islam—Alawite—No. of Adherents"
label variable islmahm "Islam—Ahmadiyya—No. of Adherents"
label variable islmothr "Islam--Other—No. of Adherents"
label variable islmgen "Islam—Total No. of Adherents"
label variable budmah "Buddhism—Mahayana—No. of Adherents"
label variable budthr "Buddhism—Theravada—No. of Adherents"
label variable budothr "Buddhism--Other—No. of Adherents"
label variable budgen "Buddhism—Total No. of Adherents"
label variable zorogen "Zoroastrian—Total No. of Adherents"
label variable hindgen "Hindu—Total No. of Adherents"
label variable sikhgen "Sikh—Total No. of Adherents"
label variable shntgen "Shinto—Total No. of Adherents"
label variable bahgen "Baha’i—Total No. of Adherents"
label variable taogen "Taoism—Total No. of Adherents"
label variable jaingen "Confucianism—Total No. of Adherents"
label variable confgen "Jain—Total No. of Adherents"
label variable syncgen "Syncretic Religions—Total No. of Adherents"
label variable anmgen "Animist Religions—Total No. of Adherents"
label variable nonrelig "Non. Religious—Total No. of Adherents"
label variable othrgen "Other Religions—Total No. of Adherents"
label variable sumrelig "Sum of Religion Adherents"
label variable pop "Total Population"
label variable chrstprotpct "Christianity—Protestants—Pct. Adherents"
label variable chrstcatpct "Christianity—Roman Catholics—Pct. Adherents"
label variable chrstorthpct "Christianity—Eastern Orthodox—Pct. Adherents"
label variable chrstangpct "Christianity—Anglican—Pct. Adherents"
label variable chrstothrpct "Christianity—Others—Pct. Adherents"
label variable chrstgenpct "Christianity—General Chrst Pct. Adherents"
label variable judorthpct "Judaism—Orthodox—Pct. Adherents"
label variable judconspct "Judaism—Conservatives—Pct. Adherents"
label variable judrefpct "Judaism—Reform—Pct. Adherents"
label variable judothrpct "Judaism--Others—Pct. Adherents"
label variable judgenpct "Judaism—General Jewish Pct. Adherents"
label variable islmsunpct "Islam—Sunni—Pct. Adherents"
label variable islmshipct "Islam—Shi’a—Pct. Adherents"
label variable islmibdpct "Islam--Ibadhi—Pct. Adherents"
label variable islmnatpct "Islam—Nation of Islam—Pct. Adherents"
label variable islmalwpct "Islam—Alawite—Pct. Adherents"
label variable islmahmpct "Islam—Ahmadiyya—Pct. Adherents"
label variable islmothrpct "Islam—Other—Pct. Adherents"
label variable islmgenpct "Islam—General Muslim Pct. Adherents"
label variable budmahpct "Buddhism—Mahayana—Pct. Adherents"
label variable budthrpct "Buddhism—Theravada—Pct. Adherents"
label variable budothrpct "Buddhism--Other—Pct. Adherents"
label variable budgenpct "Buddhism—Gen. Buddhist Pct. Adherents"
label variable zorogenpct "Zoroastrian—Zoro. Pct. Adherents"
label variable hindgenpct "Hindu—Pct. Adherents"
label variable sikhgenpct "Sikh—Pct. Adherents"
label variable shntgenpct "Shinto—Pct. Adherents"
label variable bahgenpct "Baha’i—Pct. Adherents"
label variable taogenpct "Taoism—Pct. Adherents"
label variable jaingenpct "Jain—Pct. Adherents"
label variable confgenpct "Confucianism—Pct. Adherents"
label variable syncgenpct "Syncretic Religions—Pct. Adherents"
label variable anmgenpct "Animist Religions—Pct. Adherents"
label variable nonreligpct "Non. Religious—Pct. Adherents"
label variable othrgenpct "Other Religions—Pct. Adherents"
label variable sumreligpct "Sum Percent religious adherents"
label variable total "Total population percantage check"
label variable dualrelig "Dual Religion"
label variable total "Total population percentage check"
label variable recreliab "Reliability of record=Source+datatype"
label variable reliabilevel "Level of Reliability of record"
label variable sourcecode "Code of major source used for the record"

* Changing some names in countryname


 replace countryname = "Egypt, Arab Rep." if countryname =="Egypt"
		replace countryname = "Gambia, The" if countryname=="Gambia"
        replace countryname = "Iran, Islamic Rep." if countryname =="Iran"
		replace countryname = "Lao PDR" if countryname =="Laos"
		replace countryname = "Macedonia, FYR" if countryname =="Macedonia"
		replace countryname = "Russian Federation" if countryname =="Russia"
		replace countryname = "Yemen, Rep." if countryname =="Yemen"
		replace countryname = "Syrian Arab Republic" if countryname=="Syria"
		replace countryname = "Hong Kong SAR, China" if countryname=="Hong Kong"

		
* Creating variable ctry for merge

keep if year>=2005
sort countryname, stable
encode countryname, gen(ctry)
sort ctry year


* Dropping observations for Sudan as it is pre-division

foreach x of varlist chrstprot-hindgen {
replace `x' = . if ctry==145
}



note: Keeping only unified Germany (CoW)
note: Observations for Sudan have been dropped (CoW)
note: Keeping obs for 2000, 2005 and 2010 (CoW)

save "${outdir}/cow.dta", replace

log close
